package com.wyw.learning.thread.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Java封装的仅有一个线程的情况
 *  为什么FixedThreadPool 和 SingleThreadExecutor使用的Queue是LinkedBlockingQueue
 *  因为本身这两种线程池已经无法增加线程数，只能给队列足够大。
 *
 *
 * @author Mr Wu    yewen.wu.china@gmail.com
 * @date 2021/7/4   5:40 下午
 * <p>
 * Update History:
 * Author        Time            Content
 */
public class SingleThreadExecutor {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        for (int i = 0; i< 1000; i++){
            executorService.execute(new Task());
        }
    }
}
